package exam.t2;

import java.io.File;
import java.io.IOException;

public class FileUrils {
    public void create(String src){
        File file = new File(src);
        if(!file.getParentFile().exists()){
            file.getParentFile().mkdirs();
        }
        try {
            file.createNewFile();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
    public void delete(String src) {
        File file =new File(src);
        deleteAllFile(file);
        file.getAbsolutePath();
        file.delete();
    }
    public static void deleteAllFile(File f){
        File[] fArr =f.listFiles();
        if(fArr!=null){
            for(File file:fArr){
                if(file.isDirectory()){
                    deleteAllFile(file);
                    file.getAbsolutePath();
                    file.delete();
                }else{
                    file.getAbsolutePath();
                    file.delete();
                }
            }
        }
    }
}
